Quiz assignment for week 1 of Regression


In [3]:
%matplotlib inline

In [7]:
import matplotlib.pyplot as plt
import numpy as np

In [6]:
plt.plot([1,2,3,4])
plt.ylabel('some numbers')
plt.show()



In [8]:
def graph(formula, x_range):  
    x = np.array(x_range)  
    y = eval(formula)
    plt.plot(x, y)  
    plt.show()

In [36]:
graph('4569+143*x', range(0, 20))



In [24]:
def valueInMonth(x):
    intercept = 4569
    slope = 143
    return intercept + slope * x

In [25]:
valueInMonth(10)


Out[25]:
5999

In [26]:
valueInMonth(52)


Out[26]:
12005

In [28]:
def housePriceRegression(x):
    intercept = -44850
    slope = 280.76
    return intercept + x * slope

The intercept stays the same while the slope changes depending on the units of both features and observations


In [33]:
280.76 / 0.092903 # Something is wrong


Out[33]:
3022.076789769975

In [37]:
280.76 * 10


Out[37]:
2807.6

In [38]:
3022.076789769975 * 0.9290304


Out[38]:
2807.601208830716

In [ ]: